﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace Ex03.VehicalsObjectModel
{
    public static class VehicalCreator
    {
        // Members
        private static List<string> s_AvabileTypes;

        /// <summary>
        /// Initializes the vehical creator static class
        /// </summary>
        static VehicalCreator()
        {
            s_AvabileTypes = new List<string>();
            s_AvabileTypes.Add("FuleCar");
            s_AvabileTypes.Add("ElectricCar");
            s_AvabileTypes.Add("ElectricMotocycle");
            s_AvabileTypes.Add("FuleMotocycle");
            s_AvabileTypes.Add("Truck");
        }

        /// <summary>
        /// Gets the names of all the available types to be created
        /// </summary>
        public static List<string> AvailableTypes
        {
            get
            {
                return s_AvabileTypes;
            }
        }

        /// <summary>
        /// Creates a new vehical from the factory
        /// </summary>
        /// <param name="i_VehicalType">The type of the vehical to create</param>
        /// <param name="i_LicenseNumber">The vehicals license number</param>
        /// <param name="i_value1">Can be used as doors number, or cargo load capacity</param>
        /// <param name="i_value2">Can be used as a color object</param>
        /// <returns>The newly created vehical</returns>
        public static Vehical CreateVehical(string i_VehicalType, string i_LicenseNumber, object i_value1, object i_value2)
        {
            Vehical created = null;
            
            // Check if the type is supported
            if (!s_AvabileTypes.Contains(i_VehicalType))
            {
                throw new ArgumentException(string.Format("{0} is not a supported type, try using AvailableTypes property", i_VehicalType));
            }
            else
            {
                // Create the vehical object
                if (i_VehicalType == "FuleCar")
                {
                    created = new FuleCar(i_LicenseNumber, (Color)i_value2, (int)i_value1);
                }
                else if (i_VehicalType == "ElectricCar")
                {
                    created = new ElectricCar(i_LicenseNumber, (Color)i_value2, (int)i_value1);
                }
                else if (i_VehicalType == "Truck")
                {
                    created = new Truck(i_LicenseNumber, (float)i_value1);
                }
                else if (i_VehicalType == "FuleMotocycle")
                {
                    created = new FuleMotocycle(i_LicenseNumber);
                }
                else if (i_VehicalType == "ElectricMotocycle")
                {
                    created = new ElectricMotocycle(i_LicenseNumber);
                }
            }

            return created;
        }
    }
}
